package cn.mst.vrs.controller.app.order;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.mst.vrs.common.entity.PageParam;
import cn.mst.vrs.common.entity.PageResult;
import cn.mst.vrs.controller.app.order.vo.ReservationOrderReqVO;
import cn.mst.vrs.controller.app.order.vo.ReservationOrderRespVO;
import cn.mst.vrs.service.order.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "WX - 预约订单API")
@RestController
@RequestMapping("/vrs/order/reservation")
public class ReservationOrderAppController {
    @Resource
    private OrderService orderService;

    @SaCheckLogin
    @PostMapping
    @Operation(summary = "场地预约")
    public CommonResult<String> reservation(@RequestBody ReservationOrderReqVO reqVO) {
        return success(orderService.reservation(reqVO, StpUtil.getLoginIdAsLong()));
    }

    @SaCheckLogin
    @GetMapping
    @Operation(summary = "获取场地预约订单详情")
    public CommonResult<List<ReservationOrderRespVO>> currentReservation() {
        return success(orderService.currentReservation(StpUtil.getLoginIdAsLong()));
    }

    @SaCheckLogin
    @GetMapping("/history")
    @Operation(summary = "获取场地预约历史订单")
    public CommonResult<PageResult<ReservationOrderRespVO>> historyReservation(@ParameterObject PageParam pageParam) {
        return success(orderService.historyReservation(StpUtil.getLoginIdAsLong(), pageParam));
    }
}
